<template xmlns:v-on="http://www.w3.org/1999/xhtml">
    <div id="app" class="home">
        <div class="main">
            <div class="title">
                {{newstitle}}
            </div>
            <div style="margin-top:5px;">{{date | UnFormatDates}}</div>
            <div class="content" v-html="newscontent">

            </div>
        </div>
        
    </div>
</template>
<script>
    import { mapActions, mapState } from 'vuex'
    export default {
        data() {
            return {
                newscontent:'',
                newstitle:'',
                date:'',
            }
        },
        computed: mapState(['']),
        filters: {
            // 返回日期格式化
            UnFormatDates(date) {
                if(date == ''){
                    return
                }else{
                    var y, m, d, h, f, s
                    var t = new Date(date)
                    y = t.getFullYear()
                    m = t.getMonth() + 1
                    d = t.getDate()
                    h = t.getHours()
                    f = t.getMinutes()
                    return y + '.' + (m < 10 ? '0' + m : m) + '.' + (d < 10 ? '0' + d : d) +
                    '  ' + (h<10 ? '0' + h:h) + ':' + (f<10 ? '0' + f:f)
                    }
            },
        },
        created: function () {
            var paths = location.href.split('?')[1]
            console.log(paths)
            var self = this
                self.getmobilenewsList({
                    id:paths
                }).then((data) => {
                    console.log("获取新闻列表", data)
                    if (data.code == 200) {
                        self.newstitle = data.data.title
                        self.date = data.data.createDate
                        self.newscontent = data.data.content
                    } else {
                        this.$message(data.message)
                    }
                }).catch(msg => console.log(msg))
        },
        beforeDestroy: function () {
        },
        watch: {
        },
        methods: {
            ...mapActions(['getmobilenewsList'])
        }
    }

</script>
<style scoped>
    #app {
        background-color: #fff;
        overflow-x: hidden;
        height: 100vh;
        /*border: 1px solid red;*/
        padding:1.07rem;
    }
    .title{
        color: #2d2a2a;font-size: 1.28rem;line-height: 2rem;
    }
    .content{
        min-height: 35.7rem;width: 100%;
        /*border:1px solid #000;*/
        margin:1.43rem 0;
        /*overflow-x: auto;*/
    }
     .content p{
        font-size: 20px!important;
     }
</style>